package com.vcit.exchangeGrade.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vcit.common.utils.poi.ExcelUtil;
import com.vcit.system.domain.exchangeGrade.TExchangeGrade;
import com.vcit.system.service.exchangeGrade.ITExchangeGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vcit.common.annotation.Log;
import com.vcit.common.core.controller.BaseController;
import com.vcit.common.core.domain.AjaxResult;
import com.vcit.common.enums.BusinessType;
import com.vcit.common.core.page.TableDataInfo;

/**
 * 成绩置换Controller
 * 
 * @author dff
 * @date 2025-01-17
 */
@Api("成绩置换信息管理")
@RestController
@RequestMapping("/system/grade")
public class TExchangeGradeController extends BaseController
{
    @Autowired
    private ITExchangeGradeService tExchangeGradeService;

    /**
     * 查询成绩置换列表
     */
    @ApiOperation("成绩置换信息列表")
    @PreAuthorize("@ss.hasPermi('system:grade:list')")
    @GetMapping("/list")
    public TableDataInfo list(TExchangeGrade tExchangeGrade)
    {
        startPage();
        List<TExchangeGrade> list = tExchangeGradeService.selectTExchangeGradeList(tExchangeGrade);
        return getDataTable(list);
    }

    /**
     * 导出成绩置换列表
     */
    @ApiOperation("导出成绩置换信息")
    @PreAuthorize("@ss.hasPermi('system:grade:export')")
    @Log(title = "成绩置换", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TExchangeGrade tExchangeGrade)
    {
        List<TExchangeGrade> list = tExchangeGradeService.selectTExchangeGradeList(tExchangeGrade);
        ExcelUtil<TExchangeGrade> util = new ExcelUtil<TExchangeGrade>(TExchangeGrade.class);
        util.exportExcel(response, list, "成绩置换数据");
    }

    /**
     * 获取成绩置换详细信息
     */
    @ApiOperation("获取成绩置换信息详情")
    @PreAuthorize("@ss.hasPermi('system:grade:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tExchangeGradeService.selectTExchangeGradeById(id));
    }

    /**
     * 新增成绩置换
     */
    @ApiOperation("新增成绩置换信息")
    @PreAuthorize("@ss.hasPermi('system:grade:add')")
    @Log(title = "成绩置换", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TExchangeGrade tExchangeGrade)
    {
        return toAjax(tExchangeGradeService.insertTExchangeGrade(tExchangeGrade));
    }

    /**
     * 修改成绩置换
     */
    @ApiOperation("修改成绩置换信息")
    @PreAuthorize("@ss.hasPermi('system:grade:edit')")
    @Log(title = "成绩置换", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TExchangeGrade tExchangeGrade)
    {
        return toAjax(tExchangeGradeService.updateTExchangeGrade(tExchangeGrade));
    }

    /**
     * 删除成绩置换
     */
    @ApiOperation("删除成绩置换信息")
    @PreAuthorize("@ss.hasPermi('system:grade:remove')")
    @Log(title = "成绩置换", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tExchangeGradeService.deleteTExchangeGradeByIds(ids));
    }
}
